<?php
declare(strict_types=1);

namespace App\Logic\User\Service;

use App\Logic\User\Repository\UserProfessionRepository;
use Closure;

class UserProfessionService implements UserServiceInterface
{

    public static function searchWhere(array $requestParams): Closure
    {
        return function ($query) use ($requestParams) {
            extract($requestParams);
            if (!empty($is_default)) {
                $query->where("is_default", "=", $is_default);
            }
        };
    }

    public function serviceSelect(array $requestParams): array
    {
        return (new UserProfessionRepository())->repositoryAll(self::searchWhere($requestParams), ["uid", "title"]);
    }

    public function serviceCreate(array $requestParams): array
    {
        return [];
    }

    public function serviceUpdate(array $requestParams): array
    {
        return [];
    }

    public function serviceDelete(array $requestParams): int
    {
        return 0;
    }

    public function serviceFind(array $requestParams): array
    {
        return (new UserProfessionRepository())->repositoryFind(self::searchWhere($requestParams), ["uid", "title"]);
    }
}
